package com.coin900.coin.cmd.user;

import com.google.gson.Gson;
import com.coin900.coin.cmd.ACmd;
import com.coin900.coin.cmd.CmdSign;
import com.coin900.coin.code.CmdCode;
import com.coin900.coin.persist.fu.FuUserAuthVO;
import com.coin900.coin.service.fu.IFuUserAuthService;
import com.value.mybatis.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author shui
 * @create 2017-12-01
 **/
@Controller
public class FuUserAuthListCmd extends ACmd {
    @Override
    public CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        Pagination pagination = respSign.buildPage();
        Map<String, Object> params = pagination.getParams();
        params.put("dataStatus", 1);
        List<FuUserAuthVO> fuUserAuthVOS = this.authService.loadFuUserAuthForPage(pagination);
        String source = new Gson().toJson(fuUserAuthVOS);
        respSign.setSource(source);
        respSign.setPageInfo(pagination);
        return respSign;
    }

    @Autowired
    private IFuUserAuthService authService;

    @Override
    public String getCmdCode() {
        return CmdCode.FU_USER_AUTH_LIST;
    }
}
